package com.tuliu.appupdate.updatelib;

import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.text.TextUtils;

/**
 * @author liaoyong
 * @desc 基础service
 * @date 2016/4/11 13:57
 */
public class BaseService extends Service{

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public boolean bindService(Intent service, ServiceConnection conn, int flags) {
        String action = service.getAction();
        if(!TextUtils.isEmpty(action)){
            service.setPackage(getPackageName());
        }
        return super.bindService(service, conn, flags);
    }

    @Override
    public ComponentName startService(Intent service) {
        String action = service.getAction();
        if(!TextUtils.isEmpty(action)){
            service.setPackage(getPackageName());
        }
        return super.startService(service);
    }

    @Override
    public boolean stopService(Intent name) {
        String action = name.getAction();
        if(!TextUtils.isEmpty(action)){
            name.setPackage(getPackageName());
        }
        return super.stopService(name);
    }

}
